package com.xyhuo.leetcode.y2025;

import java.util.Stack;

public class MyQueue {

    Stack<Integer>[] s = new Stack[2];

    public MyQueue() {
        s[0] = new Stack<>();
        s[1] = new Stack<>();
    }

    public void push(int x) {
        s[0].push(x);
    }

    public int pop() {
        if (s[1].isEmpty()) {
            while (!s[0].isEmpty()) {
                s[1].push(s[0].pop());
            }
        }
        return s[1].pop();
    }

    public int peek() {
        if (s[1].isEmpty()) {
            while (!s[0].isEmpty()) {
                s[1].push(s[0].pop());
            }
        }
        return s[1].peek();
    }

    public boolean empty() {
        return s[0].isEmpty() && s[1].isEmpty();
    }
}
